package com.mt.system.service.model;

import java.util.List;
import java.util.Map;

import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

import com.github.pagehelper.PageHelper;
import com.mt.common.PagerInfo;
import com.mt.common.ServiceResult;
import com.mt.system.entity.RoleMenuRelateEntity;
import com.mt.system.mapper.RoleMenuRelateEntityMapper;

@Component
public class RoleMenuRelateServiceModel {
    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(RoleMenuRelateServiceModel.class);

    @Autowired
    private RoleMenuRelateEntityMapper roleMenuRelateEntityMapper;

    public ServiceResult<List<RoleMenuRelateEntity>> selectList(Map<String, Object> params, PagerInfo<?> pagerInfo) {
        Assert.notNull(this.roleMenuRelateEntityMapper, "Property 'roleMenuRelateEntityMapper' is required.");
        ServiceResult<List<RoleMenuRelateEntity>> result = new ServiceResult<List<RoleMenuRelateEntity>>();
        try {
            if (pagerInfo != null) {
                PageHelper.startPage(pagerInfo.getPageIndex(), pagerInfo.getPageSize());
            }

            result.setResult(this.roleMenuRelateEntityMapper.selectList(params));
        } catch (Exception e) {
            result.setSuccess(false);
            result.setMessage("Unknown error!");
            LOGGER.error("[SupplierImageServiceImpl][findList]：query findList occur exception", e);
        }
        return result;
    }
}
